package controller;

import entity.UserEntity;
import frontEnd.Web;
import service.BusService;

import java.util.Scanner;

/**
 * @author HuangJH
 * @create 2023-11-30-17:50
 */
public class BusController {

    private BusService busService = new BusService();

    /**
     * 登录之后
     */
    public void afterLogin(UserEntity login) {
        Scanner scanner = new Scanner(System.in);
        switch (login.getIdentity()){
            case 1:
                // 管理员界面
                System.out.println("==========================================");
                System.out.println("欢迎管理员：" + login.getAccount() + "登录");
                while (true) {
                    System.out.println("==========================================");
                    System.out.println("0-退出登录");
                    System.out.println("1-查看班车信息");
                    System.out.println("2-添加班车信息");
                    System.out.println("3-修改班车信息");
                    System.out.println("4-删除班车信息");
                    boolean b = busService.operateBus(scanner.nextInt());
                    if(b == false) {
                        break;
                    }
                }
            case 2:
                // 用户界面
                System.out.println("==========================================");
                System.out.println("欢迎用户：" + login.getAccount() + "登录");
                while (true) {
                    System.out.println("==========================================");
                    System.out.println("0-退出登录");
                    System.out.println("1-查看所有班车信息");
                    System.out.println("2-查看已预约班车信息");
                    System.out.println("3-预约班车");
                    System.out.println("4-解约班车");
                    boolean b = busService.operateUserBusMapping(scanner.nextInt(), login.getId());
                    if(b == false) {
                        break;
                    }
                }
            default:
                break;
        }
    }
}
